package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.BaseParamBo;
import com.cskaoyan.bean.BaseRespData;
import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.pojo.Issue;
import com.cskaoyan.service.admin.IssueService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Name : IssueController.java
 * @Time : 2021/8/13 00:44
 * @Author : Xfeng
 * @Software : IntelliJ IDEA
 */

@RestController
@RequestMapping("admin/issue")
public class IssueController {

    @Autowired
    IssueService issueService;

    @RequiresPermissions(value = {"*", "admin:issue:list"}, logical = Logical.OR)
    @RequestMapping("list")
    public BaseRespVo list(String question, BaseParamBo baseParamBo) {
        BaseRespData baseRespData = issueService.list(question, baseParamBo);
        return BaseRespVo.ok(baseRespData);
    }

    @RequiresPermissions(value = {"*", "admin:issue:create"}, logical = Logical.OR)
    @RequestMapping("create")
    public BaseRespVo create(@RequestBody Issue issue) {
        Issue issue1 = issueService.create(issue);
        return BaseRespVo.ok(issue1);
    }

    @RequiresPermissions(value = {"*", "admin:issue:update"}, logical = Logical.OR)
    @RequestMapping("update")
    public BaseRespVo update(@RequestBody Issue issue) {
        Issue issue1 = issueService.update(issue);
        return BaseRespVo.ok(issue1);
    }

    @RequiresPermissions(value = {"*", "admin:issue:delete"}, logical = Logical.OR)
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody Issue issue) {
        issueService.delete(issue);
        return BaseRespVo.ok();
    }
}
